package logic

import (
	"context"
	"doc-manage/models/mysql"

	"doc-manage/docrpc/docrpc"
	"doc-manage/docrpc/internal/svc"

	"github.com/zeromicro/go-zero/core/logx"
)

type DoctorDetailLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewDoctorDetailLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DoctorDetailLogic {
	return &DoctorDetailLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

// 详情
func (l *DoctorDetailLogic) DoctorDetail(in *docrpc.DoctorDetailRequest) (*docrpc.DoctorDetailResponse, error) {
	// todo: add your logic here and delete this line
	var doctor mysql.Doctor
	err := doctor.DoctorShow(mysql.DB, in.DoctorId)
	if err != nil {
		return nil, err
	}
	return &docrpc.DoctorDetailResponse{
		DoctorId:      int64(doctor.ID),
		DoctorName:    doctor.DoctorName,
		DoctorAddress: doctor.DoctorAddress,
		DoctorDetail:  doctor.DoctorDetail,
	}, nil
}
